package com.chinadci.smartcommunitysystembackstage.controller;


import com.chinadci.smartcommunitysystembackstage.entity.ScsAdmin;
import com.chinadci.smartcommunitysystembackstage.service.ScsActivityService;
import com.chinadci.smartcommunitysystembackstage.service.ScsComplaintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@RestController
@CrossOrigin
@Api("建业E家")
public class ScsComplaintController {
    @Autowired
    private ScsComplaintService service;

    //显示全部投诉
    @ApiOperation(value = "显示所有投诉")           //swagger
    @ApiImplicitParam(name = "time",value = "投诉时间")       //表明要传入的参数
    @RequestMapping(value = "/api/ts",method = RequestMethod.GET)
    public Map Add(String time){
        Map<String,Object> map=new HashMap<>();
        map.put("data",service.Find(time));
        return map;
    }

    //处理投诉
    @ApiOperation(value = "处理投诉")           //swagger
    @ApiImplicitParam(name = "id",value = "投诉编号")       //表明要传入的参数
    @RequestMapping(value = "/api/tscl",method = RequestMethod.POST)
    public Map Clts(int id){
        Map<String,Object> map=new HashMap<>();
        if (service.Cl(id).getCState()==0){
            map.put("state",1);             //代表该投诉已经解决过
            return map;
        }
        map.put("data",service.Update(id));
        return map;
    }
}
